package com.liyongjian.xhban.dal;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import com.liyongjian.xhban.model.AccountGroupFamily;

public interface AccountGroupFamilyRepository
        extends PagingAndSortingRepository<AccountGroupFamily, Long> {

    AccountGroupFamily findByBlogId(Long blogId);

    @Query("select sum(t.money) from AccountGroupFamily t where t.groupId=:groupId and t.state=1 and t.type in (0,3)")
    Float sumSRByGroupId(@Param("groupId") Long groupId);

    @Query("select sum(t.money) from AccountGroupFamily t where t.groupId=:groupId and t.state=1 and t.type in (4,7)")
    Float sumZCByGroupId(@Param("groupId") Long groupId);

    @Query("select sum(t.money) from AccountGroupFamily t where t.groupId=:groupId and t.state=1 and t.type in (5)")
    Float sumFDByGroupId(@Param("groupId") Long groupId);

    @Query("select sum(t.money) from AccountGroupFamily t where t.groupId=:groupId and t.state=1 and t.type in (1)")
    Float sumJDByGroupId(@Param("groupId") Long groupId);

}
